#ifndef CLASSIFIER_H
#define CLASSIFIER_H

#include <QString>
#include <QFile>
#include <QDebug>
#include <QStringList>
#include <cv.h>
#include <highgui.h>
#include <ml.h>
#include <vector>
#include <iostream>
#include <fstream>
#include "mytype.h"

using namespace cv;

class Classifier
{
public:
    Classifier();
    ~Classifier();
    void pcaCompress(const QString &fileName);              // Principle Component analysis
    void trainSVM(const QString &fileName);                 // Support Vector Machines
    void trainMLP(const QString &fileName);                 // Multi-layer Perceptrons
    void trainBoost(const QString &fileName);
    bool loadSVM(const QString &fileName);                  // Load SVM from file
    bool loadMLP(const QString &fileName);                  // Load MLP from file
    bool loadBoost(const QString &fileName);
    void classify(double **dPts, QList<SeedNode *> &regions, int c_type, int dim);                 // classify a row of features

private:
    void getInputMat(const QString &fileName, Mat &inputMat, Mat &flagMat);
    void getTrainingTestMat(Mat &inputMat, Mat &trainingMat, Mat &testMat);
    void getDataMat(double **dPts, Mat &seeds, int dim);
    Mat doPCA(Mat &inputMat, int maxComp);

    CvSVM SVM;
    CvANN_MLP mlp;
    CvBoost boost;
    Mat eigenVector;
};

#endif // CLASSIFIER_H
